package com.feibiao.computer;

import java.util.Scanner;

public class Factorial implements Compute {
	private int result;

    //函数重写
    public double compute(){

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入运算数");
        int operand = scanner.nextInt();
        if (operand < 0){
            System.out.println("Sorry,负数没有阶乘");
        }else if(operand == 0){
            result = 1;
        }else{
            result = 1;
            for (int i = operand;i >= 1;i --){
                result *= i;
            }
        }
        return result;
    }
}
